package com.shujia.java.day10.demo2;


import java.util.Scanner;

//多态
public class Test {
    public static void main(String[] args) {
        Master master = new Master();
        master.setName("主人");
        System.out.println("欢迎来到宠物店");
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入要领养宠物的姓名:");
        String name=sc.next();//宠物姓名
        System.out.print("请选择要领养的宠物(1.狗 2.猫):");
        int i=sc.nextInt();
        Pet pet=master.gPet(i);
        int ii=0;
        switch (i){
            case 1:
                Dog dog=(Dog)pet;
                dog.setHealth(1);
                dog.setName(name);
                System.out.print("请选择狗的种类(1.哈士奇 2.金毛):");
                ii=sc.nextInt();
                switch (ii){
                    case 1:
                        dog.setKind("哈士奇");
                        //dog赋值给Master
                        master.setPet(dog);
                        break;
                    case 2:
                        dog.setKind("金毛");
                        //dog赋值给Master
                        master.setPet(dog);
                        break;
                }
                break;
            case 2:
                Cat cat=(Cat)pet;
                cat.setHealth(100);
                cat.setName(name);
                System.out.print("请选择的猫性别(1.公 2.母):");
                ii=sc.nextInt();
                switch (ii){
                    case 1:
                        cat.setSex("公");
                        master.setPet(cat);
                        break;
                    case 2:
                        cat.setSex("母");
                        master.setPet(cat);
                        break;
                }
        }
        master.petEat();

        master.play(pet);
    }
}
